﻿package com.eve.eplus.main;

import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.OvershootInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.eve.eplus.R;
import com.eve.eplus.common.activity.BaseActivity;
import com.eve.eplus.common.app.BaseApplication;
import com.eve.eplus.common.app.Constants;
import com.eve.eplus.sns.weibo.WeiboAPIGather;

/**
 * 关于界面
 * 
 * @author Norsie
 * @create 12-11-29
 */
public class AboutActivity extends BaseActivity
{

    LinearLayout btnFollow;
    TextView tvFocous;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_about);
        initView();
    }

    private void initView()
    {
        btnFollow = (LinearLayout) this.findViewById(R.id.id_focus);
        tvFocous =(TextView)findViewById(R.id.tv_focous);

        btnFollow.setOnClickListener(onClickListener);

    }

    OnClickListener onClickListener = new OnClickListener() {

        @Override
        public void onClick(View v)
        {
            switch (v.getId())
            {
                case R.id.id_focus:
                    // 列出所有新浪帐号 给出选择
//                    Animation miniAnimation = new ScaleAnimation(1.0f, 0f, 1.0f, 0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
//                    miniAnimation.setDuration(300);
//                    miniAnimation.setFillAfter(true);
//                    tvFocous.startAnimation(miniAnimation);
                    int xOffset = (int) (20.667 * getResources().getDisplayMetrics().density);
                    MarginLayoutParams mlp = (MarginLayoutParams) tvFocous.getLayoutParams();
                    Animation animation = new TranslateAnimation(mlp.rightMargin - xOffset, 0F, 0F, 0F);
                    animation.setFillAfter(true);
                    animation.setDuration(300);
                    animation.setInterpolator(new OvershootInterpolator(2F));// 动画的效果 弹出再回来的效果
                    tvFocous.startAnimation(animation);
                    tvFocous.setText("谢谢！");
                    btnFollow.setClickable(false);
                    new WeiboAPIGather(BaseApplication.SNS_ACCOUNT.get(0),new Handler()).setFollow(Constants.EVE_UID);
                    break;
                default:
                    break;
            }

        }
    };
}
